/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#ifndef __E_MOD_MAIN_H__
#define __E_MOD_MAIN_H__


#define SEARCH_REFRESH 10
#define MAX_SONG_LENGTH 255

#define PLAYER_XMMS 0
#define PLAYER_XMMS2 1
#define PLAYER_BMP 2
#define PLAYER_BMPX 3
#define PLAYER_AUDACIOUS 4
#define PLAYER_ECLAIR 5
#define PLAYER_AMAROK 6
#define PLAYER_MPD 7

#define THEME_DEFAULT "winter"
#define CHARSET_DEFAULT "UTF-8"

#include "e.h"
#include <glib-2.0/glib.h>
#include <iconv.h>
#include "config.h"
#ifdef HAVE_AMAROK
#include <Ecore.h>
#endif

EAPI extern E_Module_Api e_modapi;

typedef struct _Config		Config;
typedef struct _Config_Face	Config_Face;
typedef struct _Eloquence	Eloquence;
typedef struct _Eloquence_Face	Eloquence_Face;
typedef struct _Instance	Instance;

struct _Instance {
     E_Gadcon_Client	*gcc;
     Evas_Object	*o_eloquence;
     E_Menu		*main_menu;
};

struct _Config
{
   Evas_List	*faces;
};

struct _Config_Face
{
   unsigned char	enabled;
   int			allow_overlap;
   char*		theme;
   int		 	player;
   double		poll_time;
   char*	 	input_charset;
};

struct _Eloquence
{
   Evas_List		*faces;
   Eloquence_Face	*face;
   E_Menu		*config_menu;

   Config		*conf;
   E_Config_Dialog	*config_dialog;
   E_Module		*module;
};

typedef struct _Eloquence_Face
{
   Eloquence	*eloquence;
   Evas_Object  *eloquence_object;
   Evas_Object  *event_object;
   Evas_Coord   xx, yy, ww;
   Instance     *inst;

   //  E_Container	*con;
   E_Menu	*menu;
   E_Menu	*control_menu;
   Config_Face	*conf;

   /* Evas Objects */
   Evas			*evas;
   E_Gadcon_Client	*gcc;

   /* Specific Objects */
   Ecore_Timer		*update_timer;
   Ecore_Timer		*recheck_timer;
   gchar		*song;
   gchar		outbuf[MAX_SONG_LENGTH];
   gchar		*song_utf8;
   iconv_t		cd;
   union {
	gint		id;
	void		*ptr;
   } session;
   /* the following two are only used by amarok now
      need to update other players to also use them
      to save the states                             */
   int			player_running;
   int			player_shuffle;
#ifdef HAVE_AMAROK
   Ecore_Event_Handler	*exe_handler_data;
   Ecore_Event_Handler	*exe_handler_exit;
   Ecore_Exe		*exe0;
   E_Menu		*amarok_menu_score;
#endif
   int			old_player;
};

EAPI void *e_modapi_init     (E_Module *module);
EAPI int   e_modapi_shutdown (E_Module *module);
EAPI int   e_modapi_save     (E_Module *module);
EAPI int   e_modapi_info     (E_Module *module);
EAPI int   e_modapi_about    (E_Module *module);
EAPI void  _eloquence_face_cb_config_updated(Eloquence_Face *face);

void draw_text(Eloquence_Face *face);

/* xmms.c */
#ifdef HAVE_XMMS_XMMSCTRL_H
int xmms_update_song(Eloquence_Face *face);
void xmms_init_menu(E_Menu *menu, Eloquence_Face *face);
void xmms_control_play_pause(Eloquence_Face *face);
void xmms_control_track_next(Eloquence_Face *face);
void xmms_control_track_prev(Eloquence_Face *face);
void xmms_control_vol_inc(Eloquence_Face *face);
void xmms_control_vol_dec(Eloquence_Face *face);
void xmms_control_shuffle(Eloquence_Face *face);
#endif

/* bmp.c */
#ifdef HAVE_BMP_BEEPCTRL_H
int bmp_update_song(Eloquence_Face *face);
void bmp_init_menu(E_Menu *menu, Eloquence_Face *face);
void bmp_control_play_pause(Eloquence_Face *face);
void bmp_control_track_next(Eloquence_Face *face);
void bmp_control_track_prev(Eloquence_Face *face);
void bmp_control_vol_inc(Eloquence_Face *face);
void bmp_control_vol_dec(Eloquence_Face *face);
void bmp_control_shuffle(Eloquence_Face *face);
#endif

/* audacious.c */
#ifdef HAVE_AUDACIOUS_BEEPCTRL_H
int audacious_update_song(Eloquence_Face *face);
void audacious_init_menu(E_Menu *menu, Eloquence_Face *face);
void audacious_control_play_pause(Eloquence_Face *face);
void audacious_control_track_next(Eloquence_Face *face);
void audacious_control_track_prev(Eloquence_Face *face);
void audacious_control_vol_inc(Eloquence_Face *face);
void audacious_control_vol_dec(Eloquence_Face *face);
void audacious_control_shuffle(Eloquence_Face *face);
#endif

/* bmpx.c */
#ifdef HAVE_BMPX_METADATA_H
int bmpx_update_song(Eloquence_Face *face);
void bmpx_init_menu(E_Menu *menu, Eloquence_Face *face);
void bmpx_control_play_pause(Eloquence_Face *face);
void bmpx_control_track_next(Eloquence_Face *face);
void bmpx_control_track_prev(Eloquence_Face *face);
void bmpx_control_vol_inc(Eloquence_Face *face);
void bmpx_control_vol_dec(Eloquence_Face *face);
void bmpx_control_shuffle(Eloquence_Face *face);
#endif

/* amarok.c */
#ifdef HAVE_AMAROK
void amarok_init(Eloquence_Face *face);
void amarok_free(Eloquence_Face *face);
void amarok_init_menu(E_Menu *menu, Eloquence_Face *face);
int amarok_update_song(Eloquence_Face *face);
void amarok_control_play_pause(Eloquence_Face *face);
void amarok_control_track_next(Eloquence_Face *face);
void amarok_control_track_prev(Eloquence_Face *face);
void amarok_control_vol_inc(Eloquence_Face *face);
void amarok_control_vol_dec(Eloquence_Face *face);
void amarok_control_shuffle(Eloquence_Face *face);
#endif

/* mpd.c */
#ifdef HAVE_LIBMPD_LIBMPD_H
void eloquence_mpd_init_menu		(E_Menu *menu, Eloquence_Face *face);
void eloquence_mpd_connect		(void *data);
void eloquence_mpd_disconnect		(void *data);
int  eloquence_mpd_update_song		(void *data);
void eloquence_mpd_control_play_pause	(void *data);
void eloquence_mpd_control_track_next	(void *data);
void eloquence_mpd_control_track_prev	(void *data);
void eloquence_mpd_control_vol_inc	(void *data);
void eloquence_mpd_control_vol_dec	(void *data);
void eloquence_mpd_control_shuffle	(void *data);
#endif

/* xmms2.c */
#ifdef HAVE_XMMSCLIENT_XMMSCLIENT_H
void xmms2_connect(Eloquence_Face *face);
void xmms2_disconnect(Eloquence_Face *face);
void xmms2_init_menu(E_Menu *menu, Eloquence_Face *face);
int xmms2_update_song(Eloquence_Face *face);
void xmms2_control_play_pause(Eloquence_Face *face);
void xmms2_control_track_next(Eloquence_Face *face);
void xmms2_control_track_prev(Eloquence_Face *face);
void xmms2_control_shuffle(Eloquence_Face *face);
void xmms2_control_sort(Eloquence_Face *face);
#endif

#endif /* __E_MOD_MAIN_H__ */

